<?php
declare(strict_types=1);

use SixShop\Core\Middleware\AuthMiddleware;
use SixShop\News\Controller\Admin\CategoryController;
use SixShop\News\Controller\Admin\NewsController;
use SixShop\News\Controller\Admin\UploadController;
use think\facade\Route;

// 以下是在后台管理路由
// 路由前缀: /admin/news

// 在 news 插件下所有路由都设置在同一个 Group中
Route::group('news', function () {
    // 文章管理路由
    Route::get('', [NewsController::class, 'index'])->middleware(['auth']);
    Route::get(':id', [NewsController::class, 'read'])->middleware(['auth']);
    Route::post('', [NewsController::class, 'create'])->middleware(['auth']);
    Route::post(':id', [NewsController::class, 'edit'])->middleware(['auth']);
    Route::put(':id', [NewsController::class, 'update'])->middleware(['auth']);
    Route::delete(':id', [NewsController::class, 'delete'])->middleware(['auth']);

})->middleware(['auth']);

  // 上传接口
Route::post('upload', [UploadController::class, 'image'])->middleware(['auth']);

Route::group('category', function () { 
    // 分类管理路由 - 在 news 下
    Route::get('', [CategoryController::class, 'index'])->middleware(['auth']);
    Route::get(':id', [CategoryController::class, 'read'])->middleware(['auth']);
    Route::post('', [CategoryController::class, 'create'])->middleware(['auth']);
    Route::put(':id', [CategoryController::class, 'update'])->middleware(['auth']);
    Route::delete(':id', [CategoryController::class, 'delete'])->middleware(['auth']);

})->middleware(['auth']);
